﻿@model IEnumerable<AdventureWorks.Entities.Address>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

@using (Html.BeginForm("Index", "Address", FormMethod.Get))
{
	<p>Customers: @Html.DropDownList("Customer", "All")&nbsp;
	 <input type="submit" value="Filter" /></p>
}
<p>
@if (ViewBag.CustomerID == null || ViewBag.CustomerID == 0)
{
	@:Select one customer to add a address
}else
{
    @Html.ActionLink("Create New", "Create", new { CustomerID = ViewBag.CustomerID })
}
</p>
<table>
    <tr>
        <th>Address</th>
        <th>City</th>
        <th>StateProvince</th>
        <th>CountryRegion</th>
        <th>PostalCode</th>
        <th>ModifiedDate</th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.AddressLines)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.City)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StateProvince)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CountryRegion)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PostalCode)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ModifiedDate)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
            @Html.ActionLink("Details", "Details", new { id = item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.ID })
        </td>
    </tr>
}

</table>
